using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentContactTableManager class is responsible for managing BO.StudentContactTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentContactTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentContactTable objects in the database.
        /// </summary>
        /// <returns>A list with all StudentContactTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentContactTableList GetList()
        {
            return StudentContactTableDB.GetList();
        }

        /// <summary>
        /// Gets a single StudentContactTable from the database without its data.
        /// </summary>
        /// <param name="studentContactKey">The StudentContactKey of the StudentContactTable in the database.</param>
        /// <returns>A StudentContactTable object when the StudentContactKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentContactTable GetItem(int studentContactKey)
        {
            return GetItem(studentContactKey, false);
        }

        /// <summary>
        /// Gets a single StudentContactTable from the database.
        /// </summary>
        /// <param name="studentContactKey">The StudentContactKey of the StudentContactTable in the database.</param>
        /// <param name="getStudentContactTableRecords">Determines whether to load all associated StudentContactTable records as well.</param>
        /// <returns>
        /// A StudentContactTable object when the StudentContactKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentContactTable GetItem(int studentContactKey, bool getStudentContactTableRecords)
        {
            StudentContactTable myStudentContactTable = StudentContactTableDB.GetItem(studentContactKey);
            return myStudentContactTable;
        }


        /// <summary>
        /// Gets a single StudentContactTable from the database.
        /// </summary>
        /// <param name="UserAccountKey">The UserAccountKey of the StudentContactTable in the database.</param>
        /// <returns>
        /// A StudentContactTable object when the UserAccountKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentContactTable GetItemByUserAccountKey(int UserAccountKey)
        {
            StudentContactTable myStudentContactTable = StudentContactTableDB.GetItemByUserAccountKey(UserAccountKey);
            return myStudentContactTable;
        }

        /// <summary>
        /// Saves a StudentContactTable in the database.
        /// </summary>
        /// <param name="myStudentContactTable">The StudentContactTable instance to save.</param>
        /// <returns>The new StudentContactKey if the StudentContactTable is new in the database or the existing StudentContactKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(StudentContactTable myStudentContactTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int studentContactTableStudentContactKey = StudentContactTableDB.Save(myStudentContactTable);

                //  Assign the StudentContactTable its new (or existing StudentContactKey).
                myStudentContactTable.StudentContactKey = studentContactTableStudentContactKey;

                myTransactionScope.Complete();

                return studentContactTableStudentContactKey;
            }
        }

        /// <summary>
        /// Deletes a StudentContactTable from the database.
        /// </summary>
        /// <param name="myStudentContactTable">The StudentContactTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentContactTable myStudentContactTable)
        {
            return StudentContactTableDB.Delete(myStudentContactTable.StudentContactKey);
        }

        #endregion

    }

}
